exports.MallTableViewCell = UI.ListViewItem.subclass({
    
    className: "MallTableViewCell",
    
    initialize: function(reuseId,cellModel,pw) {
		//$super(reuseId);
    	this._parentWindow = pw;
    	this._cellView = null;
    	this._indexPath_Row = 0;
        this._cellModel = cellModel;
    },
    
    _onCreateView: function() {
		this._cellView = new CustomCellView();
		
		var cellBg = this.getBaseResourcePath() + "cell-background.png";

        this._cellView.setFrame([TCUtil.getAdjustedX(0),TCUtil.getAdjustedY(0),TCUtil.getAdjustedX(240),TCUtil.getAdjustedY(90)]);
        
		this._cellView.backgroundView = UIFactory.getView([TCUtil.getAdjustedX(10),TCUtil.getAdjustedY(5),TCUtil.getAdjustedX(230),TCUtil.getAdjustedY(90)], null,null);
		this._cellView.addChild(this._cellView.backgroundView);
		
		this._cellView.itemBg = UIFactory.getImage([ TCUtil.getAdjustedX(0), TCUtil.getAdjustedY(0), TCUtil.getAdjustedX(230),TCUtil.getAdjustedY(90)], cellBg);
		this._cellView.backgroundView.addChild(this._cellView.itemBg);
		
        this._cellView._mallName = UIFactory.getTextArea([TCUtil.getAdjustedX(30), TCUtil.getAdjustedY(10), TCUtil.adjustWidthWithDevice(190), TCUtil.adjustHeightWithDevice(30)], "", TCUtil.getAdjustedFontSize(100), UI.ViewGeometry.Gravity.Left, 'ffcc99');
		this._cellView.addChild(this._cellView._mallName);
		
		this._cellView._floorCount = UIFactory.getTextArea([TCUtil.getAdjustedX(30), TCUtil.getAdjustedY(50), TCUtil.adjustWidthWithDevice(170), TCUtil.adjustHeightWithDevice(30)], "", TCUtil.getAdjustedFontSize(100), UI.ViewGeometry.Gravity.Left, 'ffcc99');
		this._cellView.addChild(this._cellView._floorCount);
		
		this._cellView._BigButton = UIFactory.getGenericButton([TCUtil.getAdjustedY(10),TCUtil.getAdjustedX(5),TCUtil.getAdjustedY(230),TCUtil.getAdjustedX(90)]);
		this._cellView._BigButton.setAlpha(0.02);
		this._cellView.addChild(this._cellView._BigButton);

        return this._cellView;
    },
    _onSetView: function(cellView) 
    {	    	
    	cellView._mallName.setText(this._cellModel.getName());
    	cellView._floorCount.setText((+this._cellModel.getFloorCount())+" " + Core.Localization.getString("floors"));
    	
//		if(cellView.icon != null)
//		{
//			cellView.removeChild(cellView.icon);
//			cellView.icon = null;
//		}
//
//		var icon = new GAStoreIcon();
//		icon.setFrame([GACommonUtils.getAdjustedY(30), GACommonUtils.getAdjustedX(15 ), GACommonUtils.getAdjustedY(70), GACommonUtils.getAdjustedY(70)]);
//		icon.load(this._storageModel);
//		
//		var tempPath = TRUtil.getBasePathForResourceType(path, GAResourceType.kThumb);
//		var iconPath = tempPath+"/thumb.png";
//		
//		cellView._sell.onclick = this.onSellItemClick.bind(this, this._cellModel);
//		cellView.icon = icon;
//		cellView.addChild(cellView.icon);

		//if(!MMGameState.getCurrentUser().getHasCompletedTutorial() || (DatabaseHelper.getHasCompletedTutorial() == false))
		if(!TutorialManager.getHasCompletedTutorial())
		{
			var swingAnimation = new SwingAnimation(kSwingDirection.kSwingDirectionLeft);
			swingAnimation.setPosition([TCUtil.getAdjustedX(160),TCUtil.getAdjustedY(40)]);
			swingAnimation.createView();
			cellView._swingAnimation = swingAnimation;
			cellView.addChild(cellView._swingAnimation);
		}
		
		cellView._BigButton.onclick = function() 
        {
            this.onMallClick(this._cellModel);
        }.bind(this);
       
    },
    
    onMallClick: function(cellModel)
    {
    	MMGameLayer.startGame(cellModel);
    	
    	this._parentWindow.removeTutorialPopup();
    	this._parentWindow.removeFromParent();
		this._parentWindow.destroy();
    },
    
	getBaseResourcePath: function()
	{
		return "./Content/images/gamelayer/controllayer/mallselectionscreen/";
	},
														
	clickedButtonAtIndex: function(buttonIndex,alertView)
	{
		if (buttonIndex == 0) 
		{   
			
		} 
		else if (buttonIndex == 1) 
		{
			
		}
		
	},

    destroy: function() 
	{
    	
    },
});

